package com.jic.interaction.loginStatus.service;

import com.alibaba.fastjson.JSON;
import com.jic.common.base.vo.RestResult;
import com.jic.interaction.common.utils.HttpClientUtil;
import com.jic.interaction.loginStatus.model.LoginStatusDTO;
import com.jic.interaction.weCashier.model.vo.response.PreOrderResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;


@Service
@Slf4j
public class LoginStatusServiceImpl implements LoginStatusService {

//    @Value("${wx.loginStatusUrl}")
//    private String url;


    @Override
    public RestResult<Object> verifyLoginStatus(LoginStatusDTO loginStatusDTO) {
        String url = "https://personal.test.webank.com/m/pmbank-mbac/OAuth";
        Map<String, String> param = JSON.parseObject(JSON.toJSONString(loginStatusDTO), Map.class);
        log.debug("==========【请求参数】==========", JSON.toJSONString(loginStatusDTO));
        Map<String, String> headersMap = new HashMap<>();
        headersMap.put("Content-Type", "application/json");
        String body = null;
        try {
            body = HttpClientUtil.doRequestPost(url, param, headersMap);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.debug("==========【返回结果】==========", JSON.toJSONString(body));
        PreOrderResponse response = new PreOrderResponse();
        response.setCode("1111");
        response.setMsg("调试测试成功");
        response.setBizSeqNo("123");
        return null;
    }
}
